package com.xyz.lockAndList;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/*class MyThread implements Runnable{
    @Override
    public void run() {

    }
}*/
class MyThread2 implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        System.out.println("******* come in here");
        return 1024;
    }
}

/**
 * @author 肖咉卓
 *
 * java 多线程中，第3种获得多线程的方式
 * get 方法一般请放在最后一行
 */
public class CallableDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask futureTask=new FutureTask(new MyThread2());
        new Thread(futureTask,"A").start();
        System.out.println(futureTask.get());
    }
}
